/**
 * 
 */
package com.example.service;

import java.util.List;

import org.jsoup.helper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.example.bean.ArticleBean;
import com.example.mapper.ArticleMapper;

@Component
public class ArticleService {
	
    @Autowired
    private ArticleMapper articleMapper;

	/**
	 * 保存
	 * @author: zhangwei
	 * @date: 2021年1月27日
	 */
	public boolean save(ArticleBean articleBean) {
		return articleMapper.insert(articleBean) > 0;
	}
	
	/**
	 * 获取文章
	 * @author: zhangwei
	 * @date: 2021年1月27日
	 */
	public List<ArticleBean> findArticle(String query) {
		List<ArticleBean> articleBeans;
		if(!StringUtil.isBlank(query)) {
			articleBeans = articleMapper.select(query);
		}else {
			articleBeans = articleMapper.selectAll();
		}
		return articleBeans;
	}
}















